import pymysql

#数据库连接变量
host="localhost"
user="user"
password="666"
database="personnel_man"

db = pymysql.connect(host=host, user=user, password=password, db=database)

cursor = db.cursor()
try:
    cursor.execute("select * from department")
    results=cursor.fetchall()
    for row in results:
        dno = row[0]
        dname = row[1]
        sno = row[2]
        print(dname)
except:
    print("error")
db.close()
